﻿#region System Namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
#endregion System Namespace

#region Foreign Namespace
#endregion Foreign Namespace

#region Styx Namespace
using Styx;
using Styx.CommonBot.AreaManagement;
using Styx.CommonBot.Profiles;
using Styx.Helpers;
using Styx.Pathing;
using Styx.Plugins;
using Styx.Common;
using Styx.CommonBot;
using Styx.WoWInternals.WoWObjects;
#endregion Styx Namespace

namespace Unstucker
{
    public class Unstucker : HBPlugin
    {
        public override string Name { get { return "Unstucker"; } }
        public override string Author { get { return "Giwin"; } }
        public override Version Version { get { return new Version(1, 0); } }
        public override bool WantButton { get { return true; } }


        public override void Initialize()
        {
            Logging.Write("Unstucker - Loaded Versidd " + Version);
        }

        public override void Pulse()
        {
            if (StyxWoW.IsInGame)
            {
                if (StyxWoW.Me.IsAlive)
                {
                    List<WoWPoint> listHotspots = ProfileManager.CurrentProfile.HotspotManager.Hotspots;

                    foreach (WoWPoint hotspot in listHotspots)
                    {
                        Logging.Write(hotspot.ToString());
                        if (Navigator.CanNavigateFully(hotspot, StyxWoW.Me.Location) && hotspot.Distance(StyxWoW.Me.Location) < 100)
                        {
                            if (StyxWoW.Me.Location.Distance(hotspot) > 5)
                            {
                                Thread.Sleep(10000);
                                Logging.Write("moving...");
                                Navigator.MoveTo(hotspot);
                            }
                        }
                    }
                }
            }
        }
    }
}